set -eux

function start_django(){

python3 manage.py makemigrations

python3 manage.py migrate

mkdir -p /var/log/uwsgi

# replace dev server with uwsgi
# python3 manage.py runserver '0.0.0.0:9091'
/root/.local/bin/uwsgi uwsgi.ini &

for f in $(ls /app/logs/all*.log)
do
    echo "log $f"
    tail -f $f &
done

}

# proxy /  request to vue ui at /app/dist
# proxy /api request to django 9091
function start_nginx(){
    nginx -c /etc/nginx/nginx.conf

    tail -f /var/log/nginx/error.log &

    tail -f /var/log/nginx/access.log &
}

start_django

start_nginx

tail -f /dev/null
